import {Point} from "../../../nodeApp/static/lib/crowncad-plugin-sdk-0.0.1";
import {beltDriveModelCommand} from "./BeltDriveModelCommand";

class VBeltDriveCommand{
  query = null;
  command = null;
  pointList = [];
  deep = 0;
  radian = 0;
  constructor(query, command, pointList, deep, radian) {
    this.query = query;
    this.command = command;
    this.pointList = pointList;
    this.deep = deep;
    this.radian = radian;
  }

  //创建轮
  async createVWheel(beltDriveParams, no, type){
    if(type === 1) {
      let L = beltDriveParams.paramsWheel1.L;
      let B = beltDriveParams.paramsWheel1.B;
      if(L > B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType1) {
          case 'solidWheelType':
            result = await this.createSolidDrivingWheelType1(beltDriveParams, beltDriveParams.paramsWheel1, true, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivingWheelType1(beltDriveParams, beltDriveParams.paramsWheel1, true, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createDrivingWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel1, numHole, true, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createDrivingWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel1, numHole, true, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createDrivingWheelFourOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, true, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createDrivingWheelSixOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, true, no);
            break;
          default:
            break;
        }
        return result;
      } else if(L <= B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType1) {
          case 'solidWheelType':
            result = await this.createSolidDrivingWheelType1(beltDriveParams, beltDriveParams.paramsWheel1, false, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivingWheelType1(beltDriveParams, beltDriveParams.paramsWheel1, false, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createDrivingWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel1, numHole, false, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createDrivingWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel1, numHole, false, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createDrivingWheelFourOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, false, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createDrivingWheelSixOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel1, beltDriveParams.n1, numHole, false, no);
            break;
          default:
            break;
        }
        return result;
      }
    } else if(type === 2) {
      let L = beltDriveParams.paramsWheel2.L;
      let B = beltDriveParams.paramsWheel2.B;
      if(L > B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType2) {
          case 'solidWheelType':
            result = await this.createSolidDrivenWheelType1(beltDriveParams, beltDriveParams.paramsWheel2, true, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivenWheelType1(beltDriveParams, beltDriveParams.paramsWheel2, true, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createDrivenWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel2, numHole, true, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createDrivenWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel2, numHole, true, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createDrivenWheelFourOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, true, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createDrivenWheelSixOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, true, no);
            break;
          default:
            break;
        }
        return result;
      } else if(L <= B) {
        let result = null;
        let numHole = 4;
        switch(beltDriveParams.wheelType2) {
          case 'solidWheelType':
            result = await this.createSolidDrivenWheelType1(beltDriveParams, beltDriveParams.paramsWheel2, false, no);
            break;
          case 'spokeWheelType':
            result = await this.createSpokeDrivenWheelType1(beltDriveParams, beltDriveParams.paramsWheel2, false, no);
            break;
          case 'fourHoleWheelType':
            numHole = 4;
            result  = await this.createDrivenWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel2, numHole, false, no);
            break;
          case 'sixHoleWheelType':
            numHole = 6;
            result  = await this.createDrivenWheelOrificeType1(beltDriveParams, beltDriveParams.paramsWheel2, numHole, false, no);
            break;
          case 'fourOvalSpokeWheelType':
            numHole = 4;
            result  = await this.createDrivenWheelFourOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, false, no);
            break;
          case 'sixOvalSpokeWheelType':
            numHole = 6;
            result  = await this.createDrivenWheelSixOvalSpokeType1(beltDriveParams, beltDriveParams.paramsWheel2, beltDriveParams.n2, numHole, false, no);
            break;
          default:
            break;
        }
        return result;
      }
    }
  }

  /**************************************************
   * V带轮驱动命令Start
   * *************************************************/
  /*实心轮建模Start*/
  async createSolidDrivingWheelType1(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let sketch = this.command.sketch;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSolidWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSolidWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 5, 0);

    return {feature: extrudeCutFeature1, no: no};
  }

  async createSolidDrivenWheelType1(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSolidWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSolidWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 5, 0);

      return {feature: extrudeCutFeature1, no: no};
    }
  }
  /*实心轮建模End*/

  /*辐板轮建模Start*/
  async createSpokeDrivingWheelType1(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);

    return {feature: extrudeCutFeature1, no: no};
  }
  async createSpokeDrivenWheelType1(beltDriveParams, solidWheel, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);

      return {feature: extrudeCutFeature1, no: no};
    }
  }
  /*辐板轮建模End*/

  /*孔板轮建模Start*/
  //L>B
  async createDrivingWheelOrificeType1(beltDriveParams, solidWheel, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let datumId = 22;
    if(numHole === 6) {
      datumId = 36;
    }
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建草图3
    let sketchFeature3 = null;
    if(numHole === 4) {
      sketchFeature3 = await this.createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, 0, numHole, datumId, no++);
    }else if(numHole === 6) {
      sketchFeature3 = await this.createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, 0, numHole, datumId, no++);
    }
    //计算旋转轴y
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let d = parseFloat(solidWheel.d);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let R1 = D1 / 2;
    let axisY = 0;
    let axisX = 0;
    if(numHole === 4) {
      let holeD = (d - D1) / 2 - delta - S;
      let holeR = holeD / 2;
      axisX = 0;
      axisY = R1 + S / 2 + holeR;
    } else if(numHole === 6) {
      let diffDeltaD1 = (d - D1) / 2 - delta;
      let halfDiffDeltaD1R = R1 + diffDeltaD1 / 2;
      axisX = halfDiffDeltaD1R;
      axisY = 0;
    }
    //旋转切除1
    let revolveCutFeature1 = await beltDriveModelCommand.revolveCutAuxiliary(query, solid, sketchFeature3, extrudeCutFeature1, beltDriveParams, axisX, axisY, 0, 360, 1);
    //圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, revolveCutFeature1, beltDriveParams, numHole, 1);
    return {feature: circularFeature1, no: no};
  }
  async createDrivenWheelOrificeType1(beltDriveParams, solidWheel, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建草图3
      if(numHole === 6) {
        datumId = 36;
      }
      //孔
      let sketchFeature3 = null;
      if(numHole === 4) {
        sketchFeature3 = await this.createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, parseFloat(beltDriveParams.distance), numHole, datumId, no++);
      }else if(numHole === 6) {
        sketchFeature3 = await this.createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, parseFloat(beltDriveParams.distance), numHole, datumId, no++);
      }
      //计算旋转轴y
      let S = parseFloat(solidWheel.S);
      let D1 = parseFloat(solidWheel.D1);
      let d = parseFloat(solidWheel.d);
      let ha = parseFloat(beltDriveParams.normalVWheel.ha);
      let hf = parseFloat(beltDriveParams.normalVWheel.hf);
      let delta = parseFloat(beltDriveParams.normalVWheel.delta);
      delta = delta + ha + hf;
      let R1 = D1 / 2;
      let axisY = 0;
      let axisX = 0;
      if(numHole === 4) {
        let holeD = (d - D1) / 2 - delta - S;
        let holeR = holeD / 2;
        axisX = 0;
        axisY = R1 + S / 2 + holeR;
      } else if(numHole === 6) {
        let diffDeltaD1 = (d - D1) / 2 - delta;
        let halfDiffDeltaD1R = R1 + diffDeltaD1 / 2;
        axisX = halfDiffDeltaD1R;
        axisY = 0;
      }
      //旋转切除1
      let revolveCutFeature1 = await beltDriveModelCommand.revolveCutAuxiliary(query, solid, sketchFeature3, extrudeCutFeature1, beltDriveParams, axisX, axisY, 0, 360, 2);
      //圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, revolveCutFeature1, beltDriveParams, numHole, 2);
      return {feature: circularFeature1, no: no};
    }
  }
  /*孔板轮建模End*/

  /*四椭圆辐轮建模Start*/
  //L>B
  async createDrivingWheelFourOvalSpokeType1(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建带轮草图3
    let sketchFeature3 = await this.createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, 0, n, numHole, no++);
    if(!sketchFeature3) {
      return {feature: extrudeCutFeature1, no: no};
    }
    //创建带轮草图3的拉伸切除
    let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
    //创建带轮圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 1);// 创建圆周阵列1

    return {feature: circularFeature1, no: no};
  }
  async createDrivenWheelFourOvalSpokeType1(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid,sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建带轮草图3
      let sketchFeature3 = await this.createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, beltDriveParams.distance, n, numHole, no++);
      if(!sketchFeature3) {
        return {feature: extrudeCutFeature1, no: no};
      }
      //创建带轮草图3的拉伸切除
      let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
      //创建带轮圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 2);

      return {feature: circularFeature1, no: no};
    }
  }
  /*四椭圆辐轮建模End*/

  /*六椭圆辐轮建模Start*/
  //L>B
  async createDrivingWheelSixOvalSpokeType1(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    //创建带轮草图1
    let sketchFeature1 = null;
    if(isLGreaterB) {
      //L>B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, 22, no++);
    } else {
      //L<B
      sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, 22, no++);
    }
    //创建带轮旋转凸台
    let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid,sketchFeature1, beltDriveParams, 0, 360, 1);
    //创建草图2
    let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, 0, 8, no++);
    //拉伸切除
    let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
    //创建带轮草图3
    let sketchFeature3 = await this.createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, 0, n, numHole, no++);
    //创建带轮草图3的拉伸切除
    let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
    //创建带轮圆周阵列
    let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 1);// 创建圆周阵列1

    return {feature: circularFeature1, no: no};
  }
  async createDrivenWheelSixOvalSpokeType1(beltDriveParams, solidWheel, n, numHole, isLGreaterB, no) {
    let query = this.query;
    let datum = this.command.datum;
    let solid = this.command.solid;
    let sketchDatumFeature1 = await beltDriveModelCommand.creatLoftSketchDatum3(datum, beltDriveParams.distance);
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature1);
    if (datumEntities && datumEntities.length > 0) {
      let datumId = datumEntities[0]?.id;
      //创建带轮草图1
      let sketchFeature1 = null;
      if(isLGreaterB) {
        //L>B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      } else {
        //L<B
        sketchFeature1 = await this.createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no++);
      }
      //创建带轮旋转凸台
      let extrudeFeature1 = await beltDriveModelCommand.revolveAddendum(query, solid, sketchFeature1, beltDriveParams, 0, 360, 2);
      //创建草图2
      let sketchFeature2 = await this.createAddWheelCutSketch(beltDriveParams, solidWheel, beltDriveParams.distance, 8, no++);
      //拉伸切除
      let extrudeCutFeature1 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature2, extrudeFeature1, 0, 4, solidWheel.L * 4);
      //创建带轮草图3
      let sketchFeature3 = await this.createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, beltDriveParams.distance, n, numHole, no++);
      //创建带轮草图3的拉伸切除
      let extrudeCutFeature2 = await beltDriveModelCommand.extrudeCutAddendum(query, solid, sketchFeature3, extrudeCutFeature1, 0, 5, 0);  // 创建拉伸体
      //创建带轮圆周阵列
      let circularFeature1 = await beltDriveModelCommand.circularPattern(solid, extrudeCutFeature2, beltDriveParams, numHole, 2);// 创建圆周阵列1

      return {feature: circularFeature1, no: no};
    }
  }
  /*六椭圆辐轮建模End*/
  /**************************************************
   * V带轮驱动命令Start
   * *************************************************/

  /**************************************************
   * V带传动实现函数Start
   * *************************************************/
  /*普通轮*/
  async createAddWheelSketch(beltDriveParams, diameter, dis, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: 8});
    sketch.createCircle({centerPoint: new Point(dis, 0), circlePoint: new Point(parseFloat(dis) + parseFloat(diameter) / 2, 0)});
    sketch.createCircle({centerPoint: new Point(dis, 0), circlePoint: new Point(parseFloat(dis) + parseFloat(diameter) * 0.25 / 2, 0)});
    sketch.exitSketch();
    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  /*带*/
  async createAddBeltSketch(sketchDatumFeature, beltDriveParams, singleBeltThickness, startNumber) {
    let query = this.query;
    let command = this.command;
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {

      let entityId = datumEntities[0]?.id;
      let points = this.pointList;

      //let singleBeltThickness = parseFloat(beltDriveParams.singleBeltThickness);
      let radius1 = parseFloat(beltDriveParams.paramsWheel1.d) / 2;
      let radius2 = parseFloat(beltDriveParams.paramsWheel2.d) / 2;
      let distance = parseFloat(beltDriveParams.distance);

      let sketchFeatures = [];
      for (let i = 0; i < points.length; i++) {
        let number = i + startNumber;
        sketch.createSketch({sketchName: '草图' + number.toString(), datumId: entityId});

        //内圈
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].inPoints[0].x, points[i].inPoints[0].y),
          secondPoint: new Point(points[i].inPoints[1].x, points[i].inPoints[1].y),
          thirdPoint: new Point(-radius1 - (singleBeltThickness * i) + this.deep, 0)
        });
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].inPoints[2].x, points[i].inPoints[2].y),
          secondPoint: new Point(points[i].inPoints[3].x, points[i].inPoints[3].y),
          thirdPoint: new Point(distance + radius2 + (singleBeltThickness * i) - this.deep, 0)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].inPoints[0].x, points[i].inPoints[0].y),
          endPoint: new Point(points[i].inPoints[2].x, points[i].inPoints[2].y)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].inPoints[1].x, points[i].inPoints[1].y),
          endPoint: new Point(points[i].inPoints[3].x, points[i].inPoints[3].y)
        });

        //外圈
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].outPoints[0].x, points[i].outPoints[0].y),
          secondPoint: new Point(points[i].outPoints[1].x, points[i].outPoints[1].y),
          thirdPoint: new Point(-radius1 - (singleBeltThickness * (i + 1)) + this.deep, 0)
        });
        sketch.createArcByThreePoint({
          firstPoint: new Point(points[i].outPoints[2].x, points[i].outPoints[2].y),
          secondPoint: new Point(points[i].outPoints[3].x, points[i].outPoints[3].y),
          thirdPoint: new Point(distance + radius2 + (singleBeltThickness * (i + 1)) - this.deep, 0)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].outPoints[0].x, points[i].outPoints[0].y),
          endPoint: new Point(points[i].outPoints[2].x, points[i].outPoints[2].y)
        });
        sketch.createSketchLine({
          startPoint: new Point(points[i].outPoints[1].x, points[i].outPoints[1].y),
          endPoint: new Point(points[i].outPoints[3].x, points[i].outPoints[3].y)
        });

        sketch.exitSketch();

        let res = await command.executeIncrementCommand(command.commandScript);
        command.clearCommand();
        let currentFeature = res?.data?.modelData?.currentFeature;
        if (currentFeature && currentFeature.length > 0) {
          let sketchFeature = {
            id: currentFeature[0]?.id,
            name: currentFeature[0]?.name,
          }
          sketchFeatures.push(sketchFeature);
        }
      }
      return sketchFeatures;
    }
  }

  /*实心轮*/
  //L>B
  async createAddSolidWheelSketchType1(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let diffLB = L - B;
    let solidBotY = ((D1 - D) / 2);
    let leftX = 0.24 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    //let r1 = 0.05 * L;
    let r1 = 0.4 * solidBotY;
    let radian1 = (45 / 180) * Math.PI;

    let leftBotPnt = new Point(-L, D/2);
    let leftMidLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidRightPnt = new Point(leftBotPnt.x + (L - B), leftMidLeftPnt.y);
    let leftTopPnt = new Point(leftMidRightPnt.x, leftMidLeftPnt.y + ((d - D1)/2));
    let rightTopPnt = new Point(0, d/2);
    let rightBotPnt = new Point(0, D/2);

    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidLeftPnt1 = new Point(leftMidLeftPnt.x, leftMidLeftPnt.y - leftY);
    let leftMidLeftPnt2 = new Point(leftMidLeftPnt.x + leftX, leftMidLeftPnt.y);
    //左边中心位置圆弧点
    let leftMidRightPnt1 = new Point(leftMidRightPnt.x - r1, leftMidRightPnt.y);
    let leftMidRightPnt2 = new Point(leftMidRightPnt.x, leftMidRightPnt.y + r1);
    let leftMidRightPnt3 = new Point((leftMidRightPnt.x - r1) + r1 * Math.cos(radian1), (leftMidRightPnt.y + r1) - r1 * Math.sin(radian1));
    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidLeftPnt1, endPoint: leftMidLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidLeftPnt2, endPoint: leftMidRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidRightPnt1, secondPoint: leftMidRightPnt2, thirdPoint:leftMidRightPnt3 });
    sketch.createSketchLine({startPoint: leftMidRightPnt2, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  async createAddWheelCutSketch(beltDriveParams, solidWheel, dis, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let L = parseFloat(solidWheel.L);
    let B = parseFloat(solidWheel.B);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let R = D / 2;
    let solidBotY = (D1 - D) / 2;
    let outX = parseFloat(dis) + R + 0.35 * solidBotY;
    let radian = (10 / 180) * Math.PI;
    let inX = parseFloat(dis) + R * Math.cos(radian);
    let inY = R * Math.sin(radian);

    let point1 = new Point(inX, inY);
    let point2 = new Point(outX, inY);
    let point3 = new Point(outX, -inY);
    let point4 = new Point(inX, -inY);

    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createSketchLine({startPoint: point2, endPoint: point3});
    sketch.createSketchLine({startPoint: point3, endPoint: point4});
    sketch.createSketchLine({startPoint: point4, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSolidWheelSketchType2(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let diffLB = B - L;
    let solidBotY = d/2 - delta;
    if(diffLB < solidBotY) {
      solidBotY = diffLB;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let midX = 0.24 * solidBotY;
    let midY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let innerR = 0.2 * solidBotY;

    let radian = Math.atan(1 / 25);
    let slopeY = (diffLB - leftX) * Math.tan(radian);

    let leftBotPnt = new Point(-L, D/2);
    let leftMidLeftPnt = new Point(-B, d/2 - delta);
    let leftMidRightPnt = new Point(-L, leftMidLeftPnt.y - slopeY);
    let leftTopPnt = new Point(-B, d/2);
    let rightTopPnt = new Point(0, d/2);
    let rightBotPnt = new Point(0, D/2);

    let leftBotPnt1 = new Point(leftBotPnt.x + midX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + midY);
    let leftMidLeftPnt1 = new Point(leftMidLeftPnt.x + leftX, leftMidLeftPnt.y);
    let leftMidLeftPnt2 = new Point(leftMidLeftPnt.x, leftMidLeftPnt.y + leftY);
    let leftMidRightOPnt = new Point(leftMidRightPnt.x - innerR, leftMidRightPnt.y - innerR);
    let leftMidRightPnt1 = new Point(leftMidRightPnt.x, leftMidRightPnt.y - innerR);
    let leftMidRightPnt2 = new Point(leftMidRightPnt.x - innerR, leftMidRightPnt.y);
    let leftMidRightPnt3 = new Point(leftMidRightOPnt.x + innerR * Math.cos(4 / Math.PI), leftMidRightOPnt.y + innerR * Math.sin(4 / Math.PI));
    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);


    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidRightPnt1, secondPoint: leftMidRightPnt2, thirdPoint: leftMidRightPnt3});
    sketch.createSketchLine({startPoint: leftMidRightPnt2, endPoint: leftMidLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidLeftPnt1, endPoint: leftMidLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidLeftPnt2, endPoint: leftTopPnt});
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  /*辐板轮*/
  //L>B
  async createAddSpokeWheelSketchType1(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let S = parseFloat(solidWheel.S);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let diffLB = (L - B) / 2;
    let hollowY = (d - D1) / 2 - delta;
    let solidBotY = ((D1 - D) / 2);
    let diffTop = (B - S) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.25 * solidBotY;
    let rightY = 0.25 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let innerX = 0.2 * diffTop;
    let innerY = 0.2 * diffTop;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotY = ((L - S) / 2  - leftX - innerX) * Math.tan(radian);
    let slopeTopY = ((B - S) / 2  - topX - innerX) * Math.tan(radian);
    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-L + diffLB, D/2);
    let leftMidBotLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidBotRightPnt = new Point(leftMidBotLeftPnt.x + ((L-S)/2), leftMidBotLeftPnt.y + slopeBotY);
    let leftMidTopRightPnt = new Point(leftMidBotRightPnt.x, d/2 - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - delta);
    //上边定位点
    let leftTopPnt = new Point(leftMidTopLeftPnt.x, d/2);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-(B-S)/2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(rightMidTopleftPnt.x, leftMidBotLeftPnt.y + slopeBotY);
    let rightMidBotRightPnt = new Point(diffLB, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y - leftY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + leftX, leftMidBotLeftPnt.y);

    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y);
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt3 = new Point(leftMidBotRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidBotRightPntArcCenter.y - innerR * Math.sin(radian1));

    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y);
    let leftMidTopRightPnt3 = new Point(leftMidTopRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidTopRightPntArcCenter.y + innerR * Math.sin(radian1));

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y);
    let rightMidBotLeftPnt3 = new Point(rightMidBotLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidBotLeftPntArcCenter.y - innerR * Math.sin(radian1));

    let rightMidTopLeftPntArcCenter = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y);
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt3 = new Point(rightMidTopLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidTopLeftPntArcCenter.y + innerR * Math.sin(radian1));

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidBotRightPnt1, secondPoint: leftMidBotRightPnt2, thirdPoint: leftMidBotRightPnt3});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidTopRightPnt1, secondPoint: leftMidTopRightPnt2, thirdPoint: leftMidTopRightPnt3});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidTopLeftPnt1, secondPoint: rightMidTopLeftPnt2, thirdPoint: rightMidTopLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidBotLeftPnt1, secondPoint: rightMidBotLeftPnt2, thirdPoint: rightMidBotLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSpokeWheelSketchType2(beltDriveParams, solidWheel, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let S = parseFloat(solidWheel.S);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let diffB = (B - S) / 2;
    let diffL = L - (diffB + S);
    //if(diffL <= 0) {
    L = 0.9 * B;
    diffL = L - (diffB + S);
    //}
    let diffLLeft = 0.6 * diffL;
    let diffLRight = 0.4 * diffL;
    let solidBotY = (D1 - D) / 2;
    let diffTop = (B - S) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let innerX = 0.1 * diffTop;
    let innerY = 0.1 * diffTop;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = (diffLLeft + diffB  - leftX - innerX) * Math.tan(radian);
    let slopeTopLeftY = (diffB  - topX - innerX) * Math.tan(radian);
    let slopeBotRightY = (diffLRight - rightX - innerX) * Math.tan(radian);
    let slopeTopRightY = slopeBotLeftY;
    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B - diffLLeft, D/2);
    let leftMidBotLeftPnt = new Point(-B - diffLLeft, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffB, leftMidBotLeftPnt.y + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(-B + diffB, d/2 - delta - slopeTopLeftY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2);
    let rightTopPnt = new Point(0, d/2);

    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffB, rightMidTopRightPnt.y - slopeTopRightY);
    let rightMidBotLeftPnt = new Point(-diffB, leftMidBotLeftPnt.y + slopeBotRightY);
    let rightMidBotRightPnt = new Point(-diffB + diffLRight, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y - leftY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + leftX, leftMidBotLeftPnt.y);

    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - innerX, leftMidBotRightPnt.y);
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + innerY);
    let leftMidBotRightPnt3 = new Point(leftMidBotRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidBotRightPntArcCenter.y - innerR * Math.sin(radian1));

    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - innerY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - innerX, leftMidTopRightPnt.y);
    let leftMidTopRightPnt3 = new Point(leftMidTopRightPntArcCenter.x + innerR * Math.cos(radian1), leftMidTopRightPntArcCenter.y + innerR * Math.sin(radian1));

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + innerY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + innerX, rightMidBotLeftPnt.y);
    let rightMidBotLeftPnt3 = new Point(rightMidBotLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidBotLeftPntArcCenter.y - innerR * Math.sin(radian1));

    let rightMidTopLeftPntArcCenter = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + innerX, rightMidTopleftPnt.y);
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - innerY);
    let rightMidTopLeftPnt3 = new Point(rightMidTopLeftPntArcCenter.x - innerR * Math.cos(radian1), rightMidTopLeftPntArcCenter.y + innerR * Math.sin(radian1));

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidBotRightPnt1, secondPoint: leftMidBotRightPnt2, thirdPoint: leftMidBotRightPnt3});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByThreePoint({firstPoint: leftMidTopRightPnt1, secondPoint: leftMidTopRightPnt2, thirdPoint: leftMidTopRightPnt3});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidTopLeftPnt1, secondPoint: rightMidTopLeftPnt2, thirdPoint: rightMidTopLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByThreePoint({firstPoint: rightMidBotLeftPnt1, secondPoint: rightMidBotLeftPnt2, thirdPoint: rightMidBotLeftPnt3});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  /*四、六孔板轮*/
  async createAddFourOrificeWheelCutSketch(beltDriveParams, solidWheel, dis, numHole, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let B = parseFloat(solidWheel.B);
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let d = parseFloat(solidWheel.d);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let R = D / 2;
    let R1 = D1 / 2;
    let holeD = (d - D1) / 2 - delta - S;
    let holeR = holeD / 2;

    let point1 = new Point(-B/2 - S/2, R1 + S/2 + holeR);
    let point2 = new Point(-B/2 - S/2, R1 + S/2 + holeD + 0.1*S);
    let point3 = new Point(-B/2, R1 + S/2 + holeD);
    let point4 = new Point(-B/2 + S/2, point2.y);
    let point5 = new Point(-B/2 + S/2, point1.y);

    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createArcByThreePoint({firstPoint: point2, secondPoint: point4, thirdPoint: point3});
    sketch.createSketchLine({startPoint: point4, endPoint: point5});
    sketch.createSketchLine({startPoint: point5, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  async createAddSixOrificeWheelCutSketch(beltDriveParams, solidWheel, dis, numHole, datumId, no) {
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let B = parseFloat(solidWheel.B);
    let S = parseFloat(solidWheel.S);
    let D1 = parseFloat(solidWheel.D1);
    let D = parseFloat(solidWheel.D);
    let d = parseFloat(solidWheel.d);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let S1 = 1.5 * S;
    let S2 = 0.5 * S;
    let R = D / 2;
    let R1 = D1 / 2;
    let diffDeltaD1 = (d - D1) / 2 - delta;
    let halfDiffDeltaD1R = R1 + diffDeltaD1 / 2;

    let radian = Math.asin((S1 / 2) / halfDiffDeltaD1R);
    let radian1 = 2 * radian;
    let radian2 = 2 * Math.PI - 6 * radian1;
    let radian3 = radian2 / 6;
    let holeR = halfDiffDeltaD1R * Math.sin(radian3 / 2);
    let holeD = 2 * holeR;

    let currentS2 = halfDiffDeltaD1R - R1 - holeR;
    let i = 1;
    while(currentS2 < S2) {
      S1 = (1.5 + i / 10) * S;
      radian = Math.asin((S1 / 2) / halfDiffDeltaD1R);
      radian1 = 2 * radian;
      radian2 = 2 * Math.PI - 6 * radian1;
      radian3 = radian2 / 6;
      holeR = halfDiffDeltaD1R * Math.sin(radian3 / 2);
      holeD = 2 * holeR;
      currentS2 = halfDiffDeltaD1R - R1 - holeR
      i++;
    }

    let pnt1 = new Point(-B/2 - S/2, halfDiffDeltaD1R);
    let pnt2 = new Point(-B/2 - S/2, halfDiffDeltaD1R + holeR + 0.1*S);
    let pnt3 = new Point(-B/2, halfDiffDeltaD1R + holeR);
    let pnt4 = new Point(-B/2 + S/2, pnt2.y);
    let pnt5 = new Point(-B/2 + S/2, pnt1.y);

    let point1 = new Point(dis + pnt1.y, pnt1.x);
    let point2 = new Point(dis + pnt2.y, pnt2.x);
    let point3 = new Point(dis + pnt3.y, pnt3.x);
    let point4 = new Point(dis + pnt4.y, pnt4.x);
    let point5 = new Point(dis + pnt5.y, pnt5.x);

    sketch.createSketchLine({startPoint: point1, endPoint: point2});
    sketch.createArcByThreePoint({firstPoint: point2, secondPoint: point4, thirdPoint: point3});
    sketch.createSketchLine({startPoint: point4, endPoint: point5});
    sketch.createSketchLine({startPoint: point5, endPoint: point1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }

  /*四、六椭圆辐轮*/
  //L>B
  async createAddSixOvalSpokeWheelSketchType1(beltDriveParams, solidWheel, n, numHole, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let P = beltDriveParams.P;
    let m = numHole;
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let l = parseFloat(solidWheel.l);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;
    let diff = L - B;
    let hollowY = (d - D1) / 2 - delta;
    let solidBotY = ((D1 - D) / 2);

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let a = 0.4 * h1;
    let a2 = 0.8 * a;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let diffBA1 = (B - a) / 2;
    let diffBA2 = (B - a2) / 2;

    let diffLA1 = (L - a) / 2;

    let diffTop = (B - a) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let innerX = 0.1 * diffTop;
    let innerY = 0.1 * diffTop;
    let innerR = innerX;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = (diffLA1 -  leftX) * Math.tan(radian);
    let diffSlopeBotLeftY = f1 - slopeBotLeftY;
    let slopeBotRightY = (diffLA1 -  leftX) * Math.tan(radian);
    let diffSlopeBotRightY = f1 - slopeBotRightY;

    let slopeTopY = (diffBA2 - topX) * Math.tan(radian);
    let diffSlopeTopY = f2 - slopeTopY;

    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B - diff/2, D/2);
    let leftMidBotLeftPnt = new Point(-B - diff/2, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffBA1, D1/2 + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(-B + diffBA2, d/2 - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    let topMidPnt = new Point((leftTopPnt.x + rightTopPnt.x)/2, d/2);
    let topMidLeftPnt = new Point(topMidPnt.x - l/2, topMidPnt.y);
    let topMidRightPnt = new Point(topMidPnt.x + l/2, topMidPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffBA2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(-diffBA1, D1/2 + slopeBotRightY);
    let rightMidBotRightPnt = new Point(diff/2, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);

    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y - leftY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x  + leftX , leftMidBotLeftPnt.y);

    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - diffSlopeBotLeftY * Math.cos(radian), leftMidBotRightPnt.y - diffSlopeBotLeftY * Math.sin(radian));
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + diffSlopeBotLeftY);
    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt1.x, leftMidBotRightPnt1.y + diffSlopeBotLeftY);

    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - diffSlopeTopY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - diffSlopeTopY * Math.cos(radian), leftMidTopRightPnt.y + diffSlopeTopY * Math.sin(radian));
    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt2.x, leftMidTopRightPnt2.y - diffSlopeTopY);

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + diffSlopeBotRightY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + diffSlopeBotRightY * Math.cos(radian), rightMidBotLeftPnt.y - diffSlopeBotRightY * Math.sin(radian));
    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt2.x, rightMidBotLeftPnt2.y + diffSlopeBotRightY);

    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + diffSlopeTopY * Math.cos(radian), rightMidTopleftPnt.y + diffSlopeTopY * Math.sin(radian));
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - diffSlopeTopY);
    let rightMidTopLeftPntArcCenter = new Point(rightMidTopLeftPnt1.x, rightMidTopLeftPnt1.y - diffSlopeTopY);

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidBotRightPntArcCenter, startPoint: leftMidBotRightPnt1, endPoint: leftMidBotRightPnt2});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidTopRightPntArcCenter, startPoint: leftMidTopRightPnt1, endPoint: leftMidTopRightPnt2});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidTopLeftPntArcCenter, startPoint: rightMidTopLeftPnt1, endPoint: rightMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidBotLeftPntArcCenter, startPoint: rightMidBotLeftPnt1, endPoint: rightMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //L<B
  async createAddSixOvalSpokeWheelSketchType2(beltDriveParams, solidWheel, n, numHole, datumId, no){
    let sketch = this.command.sketch;
    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: datumId});
    let P = beltDriveParams.P;
    let m = numHole;
    let d = parseFloat(solidWheel.d);
    let D = parseFloat(solidWheel.D);
    let D1 = parseFloat(solidWheel.D1);
    let B = parseFloat(solidWheel.B);
    let L = parseFloat(solidWheel.L);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;

    let solidBotY = ((D1 - D) / 2);
    let leftL = 0.35 * L;
    let rightL = 0.65 * L;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let a = 0.4 * h1;
    let a2 = 0.8 * a;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let diffBA1 = (B - a) / 2;
    let diffBA2 = (B - a2) / 2;

    let diffTop = (B - a) / 2;
    if(diffTop > solidBotY) {
      diffTop = solidBotY;
    }
    if(diffTop > delta) {
      diffTop = delta;
    }

    let leftX = 0.2 * solidBotY;
    let leftY = 0.2 * solidBotY;
    let rightX = 0.2 * solidBotY;
    let rightY = 0.2 * solidBotY;
    let topX = 0.2 * diffTop;
    let topY = 0.2 * diffTop;
    let midBotX = 0.05 * solidBotY;
    let midBotY = 0.05 * solidBotY;

    let radian = Math.atan(1 / 25);
    let slopeBotLeftY = (leftL - midBotX - a/2) * Math.tan(radian);
    let diffSlopeBotLeftY = f1 - slopeBotLeftY;
    let slopeBotRightY = (rightL - rightX - a/2) * Math.tan(radian);
    let diffSlopeBotRightY = f1 - slopeBotRightY;

    let slopeTopY = (diffBA2 - topX) * Math.tan(radian);
    let diffSlopeTopY = f2 - slopeTopY;

    let radian1 = (45 / 180) * Math.PI;

    //左边定位点
    let leftBotPnt = new Point(-B/2 - leftL, D/2);
    let leftMidBotLeftPnt = new Point(leftBotPnt.x, D1/2);
    let leftMidBotRightPnt = new Point(-B + diffBA2, D1/2 + slopeBotLeftY);
    let leftMidTopRightPnt = new Point(leftMidBotRightPnt.x, d/2 - delta - slopeTopY);
    let leftMidTopLeftPnt = new Point(-B, d/2 - delta);
    //上边定位点
    let leftTopPnt = new Point(-B, d/2);
    let rightTopPnt = new Point(0, leftTopPnt.y);
    //右边定位点
    let rightMidTopRightPnt = new Point(0, leftMidTopLeftPnt.y);
    let rightMidTopleftPnt = new Point(-diffBA2, rightMidTopRightPnt.y - slopeTopY);
    let rightMidBotLeftPnt = new Point(rightMidTopleftPnt.x, D1/2 + slopeBotRightY);
    let rightMidBotRightPnt = new Point(-B/2 + rightL, D1/2);
    let rightBotPnt = new Point(rightMidBotRightPnt.x, D/2);

    //左边点
    let leftBotPnt1 = new Point(leftBotPnt.x + leftX, leftBotPnt.y);
    let leftBotPnt2 = new Point(leftBotPnt.x, leftBotPnt.y + leftY);
    let leftMidBotLeftPnt1 = new Point(leftMidBotLeftPnt.x, leftMidBotLeftPnt.y  - midBotY);
    let leftMidBotLeftPnt2 = new Point(leftMidBotLeftPnt.x + midBotX, leftMidBotLeftPnt.y);
    let leftMidBotRightPnt1 = new Point(leftMidBotRightPnt.x - diffSlopeBotLeftY * Math.cos(radian), leftMidBotRightPnt.y - diffSlopeBotLeftY * Math.sin(radian));
    let leftMidBotRightPnt2 = new Point(leftMidBotRightPnt.x, leftMidBotRightPnt.y + diffSlopeBotLeftY);
    let leftMidBotRightPntArcCenter = new Point(leftMidBotRightPnt1.x, leftMidBotRightPnt1.y + diffSlopeBotLeftY);

    let leftMidTopRightPnt1 = new Point(leftMidTopRightPnt.x, leftMidTopRightPnt.y - diffSlopeTopY);
    let leftMidTopRightPnt2 = new Point(leftMidTopRightPnt.x - diffSlopeTopY * Math.cos(radian), leftMidTopRightPnt.y + diffSlopeTopY * Math.sin(radian));
    let leftMidTopRightPntArcCenter = new Point(leftMidTopRightPnt2.x, leftMidTopRightPnt2.y - diffSlopeTopY);

    let leftMidTopLeftPnt1 = new Point(leftMidTopLeftPnt.x  + topX, leftMidTopLeftPnt.y);
    let leftMidTopLeftPnt2 = new Point(leftMidTopLeftPnt.x, leftMidTopLeftPnt.y + topY);

    //右边点
    let rightMidTopRightPnt1 = new Point(rightMidTopRightPnt.x, rightMidTopRightPnt.y + topY);
    let rightMidTopRightPnt2 = new Point(rightMidTopRightPnt.x - topX, rightMidTopRightPnt.y);
    let rightMidBotRightPnt1 = new Point(rightMidBotRightPnt.x - rightX, rightMidBotRightPnt.y);
    let rightMidBotRightPnt2 = new Point(rightMidBotRightPnt.x, rightMidBotRightPnt.y - rightY);

    let rightMidBotLeftPnt1 = new Point(rightMidBotLeftPnt.x, rightMidBotLeftPnt.y + diffSlopeBotRightY);
    let rightMidBotLeftPnt2 = new Point(rightMidBotLeftPnt.x + diffSlopeBotRightY * Math.cos(radian), rightMidBotLeftPnt.y - diffSlopeBotRightY * Math.sin(radian));
    let rightMidBotLeftPntArcCenter = new Point(rightMidBotLeftPnt2.x, rightMidBotLeftPnt2.y + diffSlopeBotRightY);

    let rightMidTopLeftPnt1 = new Point(rightMidTopleftPnt.x + diffSlopeTopY * Math.cos(radian), rightMidTopleftPnt.y + diffSlopeTopY * Math.sin(radian));
    let rightMidTopLeftPnt2 = new Point(rightMidTopleftPnt.x, rightMidTopleftPnt.y - diffSlopeTopY);
    let rightMidTopLeftPntArcCenter = new Point(rightMidTopLeftPnt1.x, rightMidTopLeftPnt1.y - diffSlopeTopY);

    let rightBotPnt1 = new Point(rightBotPnt.x, rightBotPnt.y + rightY);
    let rightBotPnt2 = new Point(rightBotPnt.x - rightX, rightBotPnt.y);

    //left
    sketch.createSketchLine({startPoint: leftBotPnt1, endPoint: leftBotPnt2});
    sketch.createSketchLine({startPoint: leftBotPnt2, endPoint: leftMidBotLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt1, endPoint: leftMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidBotLeftPnt2, endPoint: leftMidBotRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidBotRightPntArcCenter, startPoint: leftMidBotRightPnt1, endPoint: leftMidBotRightPnt2});
    sketch.createSketchLine({startPoint: leftMidBotRightPnt2, endPoint: leftMidTopRightPnt1});
    sketch.createArcByCenter({centerPoint: leftMidTopRightPntArcCenter, startPoint: leftMidTopRightPnt1, endPoint: leftMidTopRightPnt2});
    sketch.createSketchLine({startPoint: leftMidTopRightPnt2, endPoint: leftMidTopLeftPnt1});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt1, endPoint: leftMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: leftMidTopLeftPnt2, endPoint: leftTopPnt});
    //top
    sketch.createSketchLine({startPoint: leftTopPnt, endPoint: rightTopPnt});
    //right
    sketch.createSketchLine({startPoint: rightTopPnt, endPoint: rightMidTopRightPnt1});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt1, endPoint: rightMidTopRightPnt2});
    sketch.createSketchLine({startPoint: rightMidTopRightPnt2, endPoint: rightMidTopLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidTopLeftPntArcCenter, startPoint: rightMidTopLeftPnt1, endPoint: rightMidTopLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidTopLeftPnt2, endPoint: rightMidBotLeftPnt1});
    sketch.createArcByCenter({centerPoint: rightMidBotLeftPntArcCenter, startPoint: rightMidBotLeftPnt1, endPoint: rightMidBotLeftPnt2});
    sketch.createSketchLine({startPoint: rightMidBotLeftPnt2, endPoint: rightMidBotRightPnt1});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt1, endPoint: rightMidBotRightPnt2});
    sketch.createSketchLine({startPoint: rightMidBotRightPnt2, endPoint: rightBotPnt1});
    sketch.createSketchLine({startPoint: rightBotPnt1, endPoint: rightBotPnt2});
    sketch.createSketchLine({startPoint: rightBotPnt2, endPoint: leftBotPnt1});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      return sketchFeature;
    }
  }
  //90°扇形草图
  async createAddFourOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, dis, n, numHole, no) {
    let sketch = this.command.sketch;

    let d = parseFloat(solidWheel.d);
    let radian = 2 * Math.PI / numHole;
    let P = beltDriveParams.P;
    let m = numHole;
    let D1 = parseFloat(solidWheel.D1);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;

    let w1 = h1 / 2;
    let w2 = h2 / 2;

    let innerR = D1 / 2 + f1;
    let outerR = d / 2 - delta - f2;
    let diffR = outerR - innerR;

    //圆心
    let centerPnt = new Point(parseFloat(dis), 0);

    //下弧
    let height = Math.sqrt(Math.pow(outerR, 2) - Math.pow(w2, 2));
    let botLeftPnt1 = new Point(centerPnt.x + w1, 0);
    let botLeftPnt2 = new Point(centerPnt.x + w2, height);
    let botLeftPnt = beltDriveModelCommand.calculateIntersection(botLeftPnt1, botLeftPnt2, centerPnt, innerR, true);
    if(!botLeftPnt) {
      return null;
    }

    let botRightPnt1 = new Point(centerPnt.x + 0, w1);
    let botRightPnt2 = new Point(centerPnt.x + height, w2);
    let botRightPnt = beltDriveModelCommand.calculateIntersection(botRightPnt1, botRightPnt2, centerPnt, innerR, false);
    if(!botRightPnt) {
      return null;
    }

    //左弧
    let leftPnt1 = botLeftPnt2;

    //右弧
    let rightPnt1 = botRightPnt2;

    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: 8});
    sketch.createArcByCenter({centerPoint: centerPnt, startPoint: botRightPnt, endPoint: botLeftPnt});
    sketch.createSketchLine({startPoint: botLeftPnt, endPoint: leftPnt1});
    sketch.createArcByCenter({centerPoint: centerPnt, startPoint: rightPnt1, endPoint: leftPnt1});
    sketch.createSketchLine({startPoint: rightPnt1, endPoint: botRightPnt});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      //编辑扇形草图圆角
      await this.editSixOvalSpokeWheelSectorSketch(sketchFeature, diffR);
      return sketchFeature;
    }
  }
  //60°扇形草图
  async createAddSixOvalSpokeWheelSectorSketch(beltDriveParams, solidWheel, dis, n, numHole, no) {
    let sketch = this.command.sketch;

    let d = parseFloat(solidWheel.d);
    let radian = 2 * Math.PI / numHole;
    let P = beltDriveParams.P;
    let m = numHole;
    let D1 = parseFloat(solidWheel.D1);
    let ha = parseFloat(beltDriveParams.normalVWheel.ha);
    let hf = parseFloat(beltDriveParams.normalVWheel.hf);
    let delta = parseFloat(beltDriveParams.normalVWheel.delta);
    delta = delta + ha + hf;

    let h1 = 290 * Math.cbrt(P / (n * m));
    let h2 = 0.8 * h1;
    let f1 = 0.2 * h1;
    let f2 = 0.2 * h2;
    let w1 = h1 / 2;
    let w2 = h2 / 2;

    let innerR = D1 / 2 + f1;
    let outerR = d / 2 - delta - f2;
    let diffR = outerR - innerR;

    //圆心
    let centerPnt = new Point(parseFloat(dis), 0);
    //下弧
    let oPnt = new Point(centerPnt.x + w1,  centerPnt.y + w1 * Math.tan(radian));
    let botPnt1x = centerPnt.x + innerR * Math.cos((Math.PI / 2) - (radian / 2));
    let botPnt1y = centerPnt.y + innerR * Math.sin((Math.PI / 2) - (radian / 2));
    let offsX1 = botPnt1x - centerPnt.x - w1;

    let i = 1;
    while(offsX1 < 0) {
      f1 = (0.2 + i / 10) * h1;
      innerR = D1 / 2 + f1;
      botPnt1x = centerPnt.x + innerR * Math.cos((Math.PI / 2) - (radian / 2));
      botPnt1y = centerPnt.y + innerR * Math.sin((Math.PI / 2) - (radian / 2));
      offsX1 = botPnt1x - centerPnt.x - w1;
      i++;
    }

    let offsY1 = offsX1 * Math.tan(radian);
    let botPnt2x = botPnt1x - offsX1;
    let botPnt2y = botPnt1y + offsY1;
    let distance1 = Math.sqrt(Math.pow((botPnt2x - oPnt.x), 2) + Math.pow((botPnt2y - oPnt.y), 2));
    let botPnt3x = oPnt.x + distance1 * Math.cos(Math.PI / 6);
    let botPnt3y = oPnt.y + distance1 * Math.sin(Math.PI / 6);
    let botPnt1 = new Point(botPnt1x, botPnt1y);
    let botPnt2 = new Point(botPnt2x, botPnt2y);
    let botPnt3 = new Point(botPnt3x, botPnt3y);

    //上弧
    let topPnt1x = centerPnt.x + outerR * Math.cos((Math.PI / 2) - (radian / 2));
    let topPnt1y = centerPnt.y + outerR * Math.sin((Math.PI / 2) - (radian / 2));
    let topPnt1 = new Point(topPnt1x, topPnt1y);

    //左弧
    let radian1 = Math.asin(w2 / outerR);
    let offsY2 = outerR * Math.cos(radian1);
    let leftPnt1x = centerPnt.x + w2;
    let leftPnt1y = centerPnt.y + offsY2;
    let leftPnt1 = new Point(leftPnt1x, leftPnt1y);

    //右弧
    let radian2 = (Math.PI / 2) - radian + radian1;
    let offsX3 = outerR * Math.cos(radian2);
    let offsY3 = outerR * Math.sin(radian2);
    let rightPnt1x = centerPnt.x + offsX3;
    let rightPnt1y = centerPnt.y + offsY3;
    let rightPnt1 = new Point(rightPnt1x, rightPnt1y);

    sketch.createSketch({sketchName: '草图' + no.toString(), datumId: 8});
    sketch.createArcByThreePoint({firstPoint: botPnt2, secondPoint: botPnt3, thirdPoint: botPnt1});
    sketch.createSketchLine({startPoint: botPnt2, endPoint: leftPnt1});
    sketch.createArcByThreePoint({firstPoint: leftPnt1, secondPoint: rightPnt1, thirdPoint: topPnt1});
    sketch.createSketchLine({startPoint: rightPnt1, endPoint: botPnt3});
    sketch.exitSketch();

    let res = await this.command.executeIncrementCommand(this.command.commandScript);
    this.command.clearCommand();
    let currentFeature = res?.data?.modelData?.currentFeature;
    if (currentFeature && currentFeature.length > 0) {
      let sketchFeature = {
        id: currentFeature[0]?.id,
        name: currentFeature[0]?.name,
      }
      //编辑扇形草图圆角
      await this.editSixOvalSpokeWheelSectorSketch(sketchFeature, diffR);
      return sketchFeature;
    }
  }
  // 编辑扇形草图
  async editSixOvalSpokeWheelSectorSketch(sketchFeature, diameter) {
    if (!sketchFeature) {
      return;
    }
    let elements = await beltDriveModelCommand.getElementsByFeature(this.query, sketchFeature);
    let sketch = this.command.sketch;
    if(elements?.length > 3) {
      sketch.editSketch({sketchName: sketchFeature.name});
      sketch.createFilletCurve({curveId1:elements[1].id, curveId2:elements[2].id, radius: parseFloat(diameter) * 0.1});
      sketch.createFilletCurve({curveId1:elements[2].id, curveId2:elements[3].id, radius: parseFloat(diameter) * 0.1});
      sketch.exitEditSketch({sketchName: sketchFeature.name});
      await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
    }
  }
  /**************************************************
   * V带传动实现函数End
   * *************************************************/

  /**************************************************
   * V带传动实现函数Start
   * *************************************************/
  /*创建主动轮传动带自定义基准面草图Start*/
  //槽型更改
  async createAddVSketch1(sketchDatumFeature, beltDriveParams, no) {
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(this.query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {
      let entityId = datumEntities[0]?.id;

      let startX = parseFloat(beltDriveParams.normalVWheel.f);
      let bd = parseFloat(beltDriveParams.normalVWheel.bd);
      let ha = parseFloat(beltDriveParams.normalVWheel.ha);
      let hf = parseFloat(beltDriveParams.normalVWheel.hf);
      let r1 = parseFloat(beltDriveParams.normalVWheel.r1);
      let r2 = parseFloat(beltDriveParams.normalVWheel.r2);
      let radian = (beltDriveParams.normalVWheel.phi / 180) * Math.PI;  //32°
      let topX = ha * Math.tan(radian / 2);
      let botX = hf * Math.tan(radian / 2);
      let centerPointTopY = parseFloat(this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)) + parseFloat(this.deep));

      let angleA = 90 - (parseFloat(beltDriveParams.normalVWheel.phi) / 2); //74°
      let angleB = (180 - angleA) / 2; //53°
      let angleC = 90 - angleB; //37°
      let radianA = (angleA / 180) * Math.PI;
      let radianB = (angleB / 180) * Math.PI;
      let radianC = (angleC / 180) * Math.PI;

      //midLeft左移分量
      let r1X = r1 * Math.tan(radianC);
      let r2X = r2 * Math.tan(radianC);

      sketch.createSketch({sketchName: '草图' + no.toString(), datumId: entityId});
      let centerPointTop = new Point(-startX, centerPointTopY, 0);
      let centerPointMid = new Point(centerPointTop.x, centerPointTop.y - ha, 0);
      let centerPointBot = new Point(centerPointTop.x, centerPointMid.y - hf, 0);

      let midLeft = new Point(centerPointMid.x - bd / 2, centerPointMid.y, 0);
      let midRight = new Point(centerPointMid.x + bd / 2, centerPointMid.y, 0);
      let topLeft = new Point(midLeft.x - topX, midLeft.y + ha, 0);
      let topRight = new Point(midRight.x + topX, midRight.y + ha, 0);
      let botLeft = new Point(midLeft.x + botX, midLeft.y - hf, 0);
      let botRight = new Point(midRight.x - botX, midRight.y - hf, 0);

      let topLeftA = new Point(topLeft.x - r1X, topLeft.y, 0);
      let topLeftB = new Point(topLeft.x  + r1X * Math.cos(radianA), topLeft.y - r1X * Math.sin(radianA), 0);
      let topLeftO = new Point(topLeftA.x, topLeftA.y - r1, 0);
      let topLeftC = new Point(topLeftO.x + r1 * Math.cos(radianB), topLeftO.y + r1 * Math.sin(radianB), 0);

      let topRightA = new Point(topRight.x + r1X, topRight.y, 0);
      let topRightB = new Point(topRight.x  - r1X * Math.cos(radianA), topRight.y - r1X * Math.sin(radianA), 0);
      let topRightO = new Point(topRightA.x, topRightA.y - r1, 0);
      let topRightC = new Point(topRightO.x - r1 * Math.cos(radianB), topRightO.y + r1 * Math.sin(radianB), 0);

      let botLeftA = new Point(botLeft.x + r2X, botLeft.y, 0);
      let botLeftB = new Point(botLeft.x  - r2X * Math.cos(radianA), botLeft.y + r2X * Math.sin(radianA), 0);
      let botLeftO = new Point(botLeftA.x, botLeftA.y + r2, 0);
      let botLeftC = new Point(botLeftO.x - r2 * Math.cos(radianB), botLeftO.y - r2 * Math.sin(radianB), 0);

      let botRightA = new Point(botRight.x - r2X, botRight.y, 0);
      let botRightB = new Point(botRight.x  + r2X * Math.cos(radianA), botRight.y + r2X * Math.sin(radianA), 0);
      let botRightO = new Point(botRightA.x, botRightA.y + r2, 0);
      let botRightC = new Point(botRightO.x + r2 * Math.cos(radianB), botRightO.y - r2 * Math.sin(radianB), 0);

      let point1 = new Point(topLeftA.x, topLeftA.y + 0.1, 0);
      let point2 = new Point(topRightA.x, topRightA.y + 0.1, 0);

      let arcDistance = Math.sqrt(Math.pow(topLeftB.x - topRightB.x, 2) + Math.pow(topLeftB.y - topRightB.y, 2));
      console.log('distance: ' + arcDistance);

      sketch.createArcByThreePoint({
        firstPoint: topLeftA,
        secondPoint: topLeftB,
        thirdPoint: topLeftC
      });
      sketch.createArcByThreePoint({
        firstPoint: topRightA,
        secondPoint: topRightB,
        thirdPoint: topRightC
      });
      sketch.createArcByThreePoint({
        firstPoint: botLeftA,
        secondPoint: botLeftB,
        thirdPoint: botLeftC
      });
      sketch.createArcByThreePoint({
        firstPoint: botRightA,
        secondPoint: botRightB,
        thirdPoint: botRightC
      });

      sketch.createSketchLine({startPoint: topLeftB, endPoint: botLeftB});
      sketch.createSketchLine({startPoint: botLeftA, endPoint: botRightA});
      sketch.createSketchLine({startPoint: botRightB, endPoint: topRightB});
      sketch.createSketchLine({startPoint: topRightA, endPoint: topLeftA});

      sketch.exitSketch();

      let res = await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
      let currentFeature = res?.data?.modelData?.currentFeature;
      if (currentFeature && currentFeature.length > 0) {
        let sketchFeature = {
          id: currentFeature[0]?.id,
          name: currentFeature[0]?.name,
        }
        return sketchFeature;
      }
    }
  }
  //V带切除成槽型
  async createAddVBeltSketch1(sketchDatumFeature, beltDriveParams, no) {
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(this.query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {
      let entityId = datumEntities[0]?.id;

      let diff = (parseFloat(beltDriveParams.normalVWheel.f) - parseFloat(beltDriveParams.normalVBelt.b) / 2) ;


      sketch.createSketch({sketchName: '草图' + no.toString(), datumId: entityId});

      let point1 = new Point(-diff, this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point2 = new Point(-diff, this.pointList[0].outPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point3 = new Point(-diff - parseFloat(beltDriveParams.normalVBelt.differenceBeltWidth), this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);

      sketch.createSketchLine({startPoint: point1, endPoint: point2});
      sketch.createSketchLine({startPoint: point2, endPoint: point3});
      sketch.createSketchLine({startPoint: point3, endPoint: point1});
      sketch.exitSketch();

      let res = await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
      let currentFeature = res?.data?.modelData?.currentFeature;
      if (currentFeature && currentFeature.length > 0) {
        let sketchFeature = {
          id: currentFeature[0]?.id,
          name: currentFeature[0]?.name,
        }
        return sketchFeature;
      }
    }
  }
  async createAddVBeltSketch2(sketchDatumFeature, beltDriveParams, no) {
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(this.query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {
      let entityId = datumEntities[0]?.id;

      let diff = (parseFloat(beltDriveParams.normalVWheel.f) - parseFloat(beltDriveParams.normalVBelt.b) / 2);
      let dis  = parseFloat(beltDriveParams.normalVBelt.b) + diff;

      sketch.createSketch({sketchName: '草图' + no.toString(), datumId: entityId});
      let point1 = new Point(-dis, this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point2 = new Point(-dis, this.pointList[0].outPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point3 = new Point(-dis + parseFloat(beltDriveParams.normalVBelt.differenceBeltWidth), this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      sketch.createSketchLine({startPoint: point1, endPoint: point2});
      sketch.createSketchLine({startPoint: point2, endPoint: point3});
      sketch.createSketchLine({startPoint: point3, endPoint: point1});
      sketch.exitSketch();

      let res = await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
      let currentFeature = res?.data?.modelData?.currentFeature;
      if (currentFeature && currentFeature.length > 0) {
        let sketchFeature = {
          id: currentFeature[0]?.id,
          name: currentFeature[0]?.name,
        }
        return sketchFeature;
      }
    }
  }
  async createAddVBeltSketch3(sketchDatumFeature, beltDriveParams, no) {
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(this.query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {
      let entityId = datumEntities[0]?.id;

      let diff = (parseFloat(beltDriveParams.normalVWheel.f) - parseFloat(beltDriveParams.normalVBelt.b / 2)) ;

      sketch.createSketch({sketchName: '草图' + no.toString(), datumId: entityId});

      let point1 = new Point(diff, -this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point2 = new Point(diff, -this.pointList[0].outPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point3 = new Point(diff + parseFloat(beltDriveParams.normalVBelt.differenceBeltWidth), -this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);

      sketch.createSketchLine({startPoint: point1, endPoint: point2});
      sketch.createSketchLine({startPoint: point2, endPoint: point3});
      sketch.createSketchLine({startPoint: point3, endPoint: point1});
      sketch.exitSketch();

      let res = await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
      let currentFeature = res?.data?.modelData?.currentFeature;
      if (currentFeature && currentFeature.length > 0) {
        let sketchFeature = {
          id: currentFeature[0]?.id,
          name: currentFeature[0]?.name,
        }
        return sketchFeature;
      }
    }
  }
  async createAddVBeltSketch4(sketchDatumFeature, beltDriveParams, no) {
    let sketch = this.command.sketch;
    if (!sketch || !sketchDatumFeature) {
      return;
    }
    let datumEntities = await beltDriveModelCommand.getEntitiesByFeature(this.query, sketchDatumFeature);
    if (datumEntities && datumEntities.length > 0) {
      let entityId = datumEntities[0]?.id;

      let diff = (parseFloat(beltDriveParams.normalVWheel.f) - parseFloat(beltDriveParams.normalVBelt.b / 2));
      let dis  = parseFloat(beltDriveParams.normalVBelt.b) + diff;

      sketch.createSketch({sketchName: '草图' + no.toString(), datumId: entityId});

      let point1 = new Point(dis, -this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point2 = new Point(dis, -this.pointList[0].outPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);
      let point3 = new Point(dis - parseFloat(beltDriveParams.normalVBelt.differenceBeltWidth), -this.pointList[0].inPoints[0].y / Math.cos(this.radian - (Math.PI / 2)), 0);

      sketch.createSketchLine({startPoint: point1, endPoint: point2});
      sketch.createSketchLine({startPoint: point2, endPoint: point3});
      sketch.createSketchLine({startPoint: point3, endPoint: point1});
      sketch.exitSketch();

      let res = await this.command.executeIncrementCommand(this.command.commandScript);
      this.command.clearCommand();
      let currentFeature = res?.data?.modelData?.currentFeature;
      if (currentFeature && currentFeature.length > 0) {
        let sketchFeature = {
          id: currentFeature[0]?.id,
          name: currentFeature[0]?.name,
        }
        return sketchFeature;
      }
    }
  }
  /*创建主动轮传动带自定义基准面草图End*/
  /**************************************************
   * V带传动实现函数End
   * *************************************************/
}

const vBeltDriveCommand = new VBeltDriveCommand();
export {vBeltDriveCommand};
